package org.nf.shopping.controller;

import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.nf.shopping.common.vo.ResultVO;
import org.nf.shopping.entity.Assemble;
import org.nf.shopping.service.AssembleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author czl
 * @Date 2024-12-08
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/assemble")
public class AssembleController extends BaseController{
    private final AssembleService assembleService;

    @GetMapping("/listAssemble")
    public ResultVO<PageInfo<Assemble>> listAssemble(Integer limit, Integer page, String typeName){
        PageInfo<Assemble> pageInfo = assembleService.listAssemble(limit, page, typeName);
        return success(pageInfo);
    }

    @PostMapping("/updateAssemble")
    public ResultVO updateAssemble(Assemble assemble){
        assembleService.updateAssemble(assemble);
        return success();
    }

    @PostMapping("/deloneAssemble")
    public ResultVO deloneAssemble(Integer id){
        assembleService.deloneAssemble(id);
        return success();
    }

    @PostMapping("/addAssemble")
    public ResultVO addAssemble(Assemble assemble){
        assembleService.addAssemble(assemble);
        return success();
    }

    @PostMapping("/getAssembleList")
    public ResultVO<List<Assemble>> getAssembleList(){
        return success(assembleService.getAssembleList());
    }
}
